import java.util.*;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class code2 {
    public static int n,m;
    public static int x1,y1;//记录起点
    public static char[][] arr = new char[35][35];//记录迷宫
    public static int[][] dist = new int[35][35];//记录每个位置到起点的距离

    public static int[] dx = {0,0,-1,1};
    public static int[] dy = {1,-1,0,0};

    public static void bfs() {
        //初始化dist
        for(int i=0;i<n;i++) {
            for(int j=0;j<m;j++) {
                dist[i][j]=-1;
            }
        }
        Queue<int[]> q = new LinkedList<>();
        q.add(new int[]{x1,y1});
        dist[x1][y1]=0;

        while(!q.isEmpty()) {
            int[] tmp = q.poll();
            int a = tmp[0],b = tmp[1];
            for(int i=0;i<4;i++) {
                int x = a+dx[i],y=b+dy[i];
                if(x>=0&&x<n&&y>=0&&y<m&&arr[x][y]!='*'&&dist[x][y]==-1) {
                    dist[x][y] = dist[a][b]+1;
                    if(arr[x][y]!='e') {
                        q.add(new int[]{x,y});
                    }
                }
            }
        }
    }
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        n = in.nextInt();m = in.nextInt();
        //记录迷宫
        for(int i=0;i<n;i++) {
            char[] tmp = in.next().toCharArray();
            for(int j=0;j<m;j++) {
                arr[i][j] = tmp[j];
                if(arr[i][j]=='k') {
                    x1=i;y1=j;
                }
            }
        }

        bfs();

        //更新结果
        int count = 0,ret = 1000;
        for(int i=0;i<n;i++) {
            for(int j=0;j<m;j++) {
                if(dist[i][j]!=-1&&arr[i][j]=='e') {
                    count++;
                    ret = Math.min(ret,dist[i][j]);
                }
            }
        }
        if(count==0) System.out.print(-1);
        else System.out.print(count+" "+ret);
    }
}
